package com.ticket.sass.admin.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ticket.sass.admin.mapper.ResourceMapper;
import com.ticket.sass.admin.service.BaseService;
import com.ticket.sass.common.entity.tenant.ResourceEntity;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author ywb
 * @date 2022-01-07 15:31
 */
@Repository
public class ResourceServiceImpl extends ServiceImpl<ResourceMapper, ResourceEntity> implements BaseService<ResourceEntity> {

    public List<ResourceEntity> listByAdminId(Integer adminId) {
        return this.baseMapper.listByAdminId(adminId);
    }

    public List<Integer> getResourceByParentId(Integer pid) {
        QueryWrapper<ResourceEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq( "parent_id", pid);
        queryWrapper.select("id");
        return this.listObjs(queryWrapper, o -> Integer.valueOf(o.toString()));
    }
}
